import Layout from '@/page/index/index.vue'


let autoRouterViews = import.meta.glob(`../../views/**/**/autoRouter.js`, {eager: true, import: "default"})

let pageRouters = [
    {
        path: '/wel',
        component: () => {
            // if(commonStore.isMacOs){
            //   return   import('@/mac/index.vue')
            // }
            return import('@/page/index/index.vue')
        },
        redirect: '/wel/index',
        children: [
            {
                path: 'index',
                name: '首页',
                meta: {
                    i18n: 'dashboard'
                },
                component: () => import( '@/views/wel/index.vue')
            },
            {
                path: 'more',
                name: '控制台',
                meta: {
                    i18n: 'more', menu: false,
                },
                component: () => import( '@/views/wel/dashboard.vue')
            }
        ]
    },
    {
        path: '/iframe',
        component: Layout,
        redirect: '/iframe',
        children: [
            {
                path: '',
                name: '',
                component: () => import('@/components/iframe/main.vue')
            }
        ]
    },
    {
        path: '/info',
        component: Layout,
        redirect: '/info/index',
        children: [
            {
                path: 'index',
                name: '个人信息',
                meta: {
                    i18n: 'info'
                },
                component: () => import( '@/views/user/info.vue')
            },
            {
                path: 'setting',
                name: '个人设置',
                meta: {
                    i18n: 'setting'
                },
                component: () => import( '@/views/user/setting.vue')
            }]
    },


]


function getAutoRouterView(autoRouterView) {
    if (autoRouterViews instanceof Array) {
        return autoRouterViews[key]
    }
    if (!autoRouterView.routes) {
        return []
    }
    autoRouterView = autoRouterView.routes
    if (!(autoRouterView instanceof Array)) {
        return []
    }
    return autoRouterView;

}

for (let key in autoRouterViews) {
    let autoRouterView = getAutoRouterView(autoRouterViews[key]);
    if (!autoRouterView || autoRouterView.length < 1) {
        continue
    }
    pageRouters = pageRouters.concat(autoRouterView)
}
export default pageRouters
